# coding:utf-8

def get_baidu_search_header(word=None, page=1):
    "获取百度搜索的 headers、url、data"

    # 获取识别码
    unique_code = word.split(' ')[-1]

    # 百度url上的规则： (':'是'%3A')(' '是'%20')
    word_baidu = word.replace(':', '%3A').replace(' ', '%20')
    print(word_baidu, unique_code)

    # url
    url = "https://www.baidu.com/s?ie=utf-8&wd=" + word_baidu + "&pn=" + str(page * 10 - 10)
    # url = 'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&wd=' + word_baidu         # url = "https://www.baidu.com/s?ie=utf-8&mod=1&isbd=1&isid=cb5ea8c100039e03&ie=utf-8&f=8&rsv_bp=1&srcqid=3246013787370268744&tn=50000021_hao_pg&wd=Mj3u4rBG&oq=Mj%2526lt%253Bu4rBG&rsv_pq=cb5ea8c100039e03&rsv_t=a244HdKKpXzA2TaA70J1hv%2BUcyI9NFn1MVQvFrhwy3v3m3HP%2FMggBfi%2BPt%2BwQegmBd9s5qha&rqlang=cn&rsv_enter=0&bs=Mj3u4rBG&rsv_sid=undefined&_ss=1&clist=7f91e0c2a4bfa8cc&hsug=&f4s=1&csor=0&_cr1=28939"
    # url = "https://www.baidu.com/s?ie=utf-8&mod=1&isbd=1&isid=cb5ea8c100039e03&ie=utf-8&f=8&rsv_bp=1&srcqid=3246013787370268744&tn=50000021_hao_pg&wd="+unique_code+"&oq=Mj%2526lt%253Bu4rBG&rsv_pq=cb5ea8c100039e03&rsv_t=a244HdKKpXzA2TaA70J1hv%2BUcyI9NFn1MVQvFrhwy3v3m3HP%2FMggBfi%2BPt%2BwQegmBd9s5qha&rqlang=cn&rsv_enter=0&bs=Mj3u4rBG&rsv_sid=undefined&_ss=1&clist=7f91e0c2a4bfa8cc&hsug=&f4s=1&csor=0&_cr1=28939"
    headers = {
        "Accept": "*/*",
        "Host": "www.baidu.com",
        # "is_pbs": word,  # "Mj3u4rBG",  # 不变
        "is_xhr": "1",
        # 这的词变
        # "Referer": "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&srcqid=3246013787370268744&tn=50000021_hao_pg&wd=Mj3u4rBG&oq=Mj%2526lt%253Bu4rBG&rsv_pq=cb5ea8c100039e03&rsv_t=a244HdKKpXzA2TaA70J1hv%2BUcyI9NFn1MVQvFrhwy3v3m3HP%2FMggBfi%2BPt%2BwQegmBd9s5qha&rqlang=cn&rsv_enter=0",
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36",
        "X-Requested-With": "XMLHttpRequest"
    }
    data = {
        "ie": "utf-8",
        "mod": "1",
        "isbd": "1",
        "isid": "cb5ea8c100039e03",
        "ie": "utf-8",
        "f": "8",
        "rsv_bp": "1",
        "srcqid": "3246013787370268744",
        "tn": "50000021_hao_pg",
        "wd": word,  # "Mj3u4rBG",  # 不变
        "pn": page * 10 - 10,
        # "oq": "Mj%26lt%3Bu4rBG",  # 这个的符号要修改
        "rsv_pq": "cb5ea8c100039e03",
        "rsv_t": "a244HdKKpXzA2TaA70J1hv+UcyI9NFn1MVQvFrhwy3v3m3HP/MggBfi+Pt+wQegmBd9s5qha",
        "rqlang": "cn",
        "rsv_enter": "0",
        "bs": word,  # "Mj3u4rBG",
        "rsv_sid": "undefined",
        "_ss": "1",
        "clist": "7f91e0c2a4bfa8cc",
        "hsug": word.lower(), # 英文的话都是小写
        "f4s": "1",
        "csor": "0",
        "_cr1": "28939" #
    }

    return url,headers,data


def get_360_search_header(world=None,page=1):
    "获取360搜索的 headers、url、data"
    pass
    # return url,headers,data
